import shutil
from core import generate_file_from_template
from util import lower_first_letter, capitalize_first_letter
import os
os.chdir(os.path.dirname(os.path.abspath(__file__)))

project = ''
module = 'util'
action = 'captcha'
package = 'com.liarjo.mywebsiteapi'

outputs_folder = './outputs'
shutil.rmtree(outputs_folder)
os.makedirs(outputs_folder)
os.makedirs(outputs_folder + '/' + module, exist_ok=True)
os.makedirs(outputs_folder + '/' + module + '/' + action, exist_ok=True)

variables = {
    'pr': project,
    'p': package,
    'lM': module,
    'cM': capitalize_first_letter(module),
    'lA': action,
    'cA': capitalize_first_letter(action),
}

generate_file_from_template('pojo', outputs_folder, **variables)
generate_file_from_template('controller', outputs_folder, **variables)
generate_file_from_template('mapper', outputs_folder, **variables)
generate_file_from_template('baseMapper', outputs_folder, **variables)
generate_file_from_template('request', outputs_folder + '/' + module, **variables)
generate_file_from_template('result', outputs_folder + '/' + module, **variables)
generate_file_from_template('service', outputs_folder, **variables)
generate_file_from_template('xml', outputs_folder, **variables)
print(f"File generated successfully")
